/***************************************************************************
 *   Copyright (C) 2009 by Bernhard Neuhofer   *
 *   mail@bneu.at   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include "taxiStandRollbackableAdapter.h"
#include "rollbackableAdapter.h"
#include "modelentity.h"
#include "memento.h"
#include "taxiStand.h"


/**
 * @see RollbackableAdapter#createMemento
 * @param modelentity 
 * @return 
 */
Memento* TaxiStandRollbackableAdapter::createMemento(ModelEntity* modelentity)
{
return new TaxiStandRollbackableMemento(
	dynamic_cast<TaxiStand*>(modelentity)->getNrCustomers(),
	dynamic_cast<TaxiStand*>(modelentity)->getNrTaxis());
}


/**
 * @see RollbackableAdapter#setMemento
 * @param modelentity 
 * @param memento 
 */
void TaxiStandRollbackableAdapter::setMemento(ModelEntity* modelentity,Memento* memento)
{
	TaxiStand* taxistandtmp				=dynamic_cast<TaxiStand*> ( modelentity);
	TaxiStandRollbackableMemento* tsmementotmp	=dynamic_cast<TaxiStandRollbackableAdapter::TaxiStandRollbackableMemento*>(memento);
		
	taxistandtmp->setNrCustomers(tsmementotmp->getNrCustomers());
	taxistandtmp->setNrTaxis(tsmementotmp->getNrTaxis());

}

/**
 * Get the number of waiting cutsomers
 * @return The number of waiting customers
 */
unsigned int TaxiStandRollbackableAdapter::TaxiStandRollbackableMemento::getNrCustomers()
{
return _nrCustomers;
}

/**
 * Get the number of waiting taxis 
 * @return The number of waiting taxis 
 */
unsigned int TaxiStandRollbackableAdapter::TaxiStandRollbackableMemento::getNrTaxis()
{
return _nrTaxis;
}

/**
 * Set the number of waiting customers
 * @param nrCustomers The number of customers
 */
void TaxiStandRollbackableAdapter::TaxiStandRollbackableMemento::setNrCustomers(unsigned int nrCustomers)
{
  _nrCustomers=nrCustomers;
}

/**
 * Set the number of waiting taxis 
 * @param nrTaxis The number of Taxis
 */
void TaxiStandRollbackableAdapter::TaxiStandRollbackableMemento::setNrTaxis(unsigned int nrTaxis)
{
_nrTaxis=nrTaxis;
}